package com.yvtian.pu.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yvtian.om.pojo.OmCustomerEntity;
import com.yvtian.pu.pojo.PuSupplierEntity;
import com.yvtian.pu.dao.PuSupplierMapper;
import com.yvtian.pu.service.PuSupplierService;
import com.yvtian.utils.StringHelper;
import org.springframework.stereotype.Service;

/**
 * (pu_supplier)表服务实现类
 *
 * @author long
 * @since 2024-05-08 14:40:40
 */
@Service("puSupplierService")
public class PuSupplierServiceImpl extends ServiceImpl<PuSupplierMapper, PuSupplierEntity> implements PuSupplierService {

    @Override
    public IPage<PuSupplierEntity> findByPage(Page<PuSupplierEntity> page, PuSupplierEntity puSupplierEntity) {
        LambdaQueryWrapper<PuSupplierEntity> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(PuSupplierEntity::getIsDel,0);
        if (puSupplierEntity.getId() != null){
            queryWrapper.eq(PuSupplierEntity::getIsDel,puSupplierEntity.getId());
        }
        if (StringHelper.isNotEmpty(puSupplierEntity.getCode())){
            queryWrapper.like(PuSupplierEntity::getCode,puSupplierEntity.getCode());
        }
        if (StringHelper.isNotEmpty(puSupplierEntity.getName())){
            queryWrapper.like(PuSupplierEntity::getName,puSupplierEntity.getName());
        }
        if (StringHelper.isNotEmpty(puSupplierEntity.getShortname())){
            queryWrapper.like(PuSupplierEntity::getShortname,puSupplierEntity.getShortname());
        }
        if (StringHelper.isNotEmpty(puSupplierEntity.getWContacts())){
            queryWrapper.like(PuSupplierEntity::getWContacts,puSupplierEntity.getWContacts());
        }
        return this.page(page, queryWrapper);
    }
}

